
package com.jl.cloud.consumer.service.kafka;

import lombok.extern.slf4j.Slf4j;
import org.apache.kafka.clients.consumer.ConsumerRecord;
import org.springframework.kafka.annotation.KafkaListener;
import org.springframework.kafka.annotation.TopicPartition;
import org.springframework.stereotype.Component;

/**
 * kafka 消费者
 *
 * @author lu.chen@eslink.cc
 */
@Component
@Slf4j
public class KafkaConsumer {

    /**
     * 监听主题，单条消费
     */
    @KafkaListener(groupId = "kafka-consumer-1",topicPartitions = {@TopicPartition(topic = "${kafka.topic.defaultTopic}",partitions = {"0"})})
    public void listen(ConsumerRecord<String, String> record) {
        log.info("接收消息kafka2 msg :  " + record.value() + ", key: " + record.key());
    }





}
